#include "drv_dma.h"
#include "stdio.h"
void drv_dma2_init(uint32_t size,uint32_t *drc,uint32_t *src)
{
	DMA_InitTypeDef DMA_InitStruct ;
	RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_DMA2, ENABLE);

	DMA_InitStruct.DMA_BufferSize = size ;//需要传输数据数量
	DMA_InitStruct.DMA_Channel = DMA_Channel_0 ;//通道号
	DMA_InitStruct.DMA_DIR = DMA_DIR_MemoryToMemory ;//内存到内存
	DMA_InitStruct.DMA_FIFOMode = DMA_FIFOMode_Disable ;//不适用FIFO模式
	DMA_InitStruct.DMA_Memory0BaseAddr = (uint32_t)drc ;//目标地址
	DMA_InitStruct.DMA_MemoryBurst = DMA_MemoryBurst_Single ;//单次触发
	DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_Word ;//数据全字（32bit）传输
	DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable ;//目标地址自增
	DMA_InitStruct.DMA_Mode = DMA_Mode_Normal ;//普通缓存模式

	DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)src ;//数据来源地址
	DMA_InitStruct.DMA_PeripheralBurst = DMA_PeripheralBurst_Single ;//单次
	DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word ;//全字
	DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Enable ;//来源地址自增
	DMA_InitStruct.DMA_Priority = DMA_Priority_High ;//优先级高

	DMA_Init(DMA2_Stream0, &DMA_InitStruct) ;//初始化参数
	DMA_Cmd(DMA2_Stream0, ENABLE) ;//使能

}

extern uint32_t buf1[5];
extern uint32_t buf2[5];
void drv_dmaData_compare(uint32_t *src,uint32_t *drc)
{
	int i ;
	for (i = 0; i < 5; ++i)
	{
		if (src[i]!=drc[i])
		{
			printf("error!");
//			printf("src:%x",buf1[i]);
//			printf("drc:%x",buf2[i]);
			return ;
		}
		printf("drc:%x",drc[i]);
	}
	
}
